home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow_WinXP / VMR / VMRXcl / d3dtextr.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  3.5 KB  |  89 lines

  1. //-----------------------------------------------------------------------------
  2. // File: D3DTextr.h
  3. //
  4. // Desc: Functions to manage textures, including creating (loading from a
  5. //       file), restoring lost surfaces, invalidating, and destroying.
  6. //
  7. //       Note: the implementation of these functions maintains an internal list
  8. //       of loaded textures. After creation, individual textures are referenced
  9. //       via their ASCII names.
  10. //
  11. // Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved
  12. //-----------------------------------------------------------------------------
  13. #ifndef D3DTEXTR_H
  14. #define D3DTEXTR_H
  15. #include <ddraw.h>
  16. #include <d3d.h>
  17.  
  18.  
  19. //-----------------------------------------------------------------------------
  20. // Access functions for loaded textures. Note: these functions search
  21. // an internal list of the textures, and use the texture associated with the
  22. // ASCII name.
  23. //-----------------------------------------------------------------------------
  24. LPDIRECTDRAWSURFACE7 D3DTextr_GetSurface( TCHAR* strName );
  25.  
  26.  
  27. //-----------------------------------------------------------------------------
  28. // Texture invalidation and restoration functions
  29. //-----------------------------------------------------------------------------
  30. HRESULT D3DTextr_Invalidate( TCHAR* strName );
  31. HRESULT D3DTextr_Restore( TCHAR* strName, LPDIRECT3DDEVICE7 pd3dDevice );
  32. HRESULT D3DTextr_InvalidateAllTextures();
  33. HRESULT D3DTextr_RestoreAllTextures( LPDIRECT3DDEVICE7 pd3dDevice );
  34.  
  35.  
  36. //-----------------------------------------------------------------------------
  37. // Texture creation and deletion functions
  38. //-----------------------------------------------------------------------------
  39. #define D3DTEXTR_TRANSPARENTWHITE 0x00000001
  40. #define D3DTEXTR_TRANSPARENTBLACK 0x00000002
  41. #define D3DTEXTR_32BITSPERPIXEL   0x00000004
  42. #define D3DTEXTR_16BITSPERPIXEL   0x00000008
  43. #define D3DTEXTR_CREATEWITHALPHA  0x00000010
  44.  
  45.  
  46. HRESULT D3DTextr_CreateTextureFromFile( TCHAR* strName, DWORD dwStage=0L,
  47.                                         DWORD dwFlags=0L );
  48. HRESULT D3DTextr_CreateEmptyTexture( TCHAR* strName, DWORD dwWidth,
  49.                                      DWORD dwHeight, DWORD dwStage,
  50.                                      DWORD dwFlags );
  51. HRESULT D3DTextr_DestroyTexture( TCHAR* strName );
  52. VOID    D3DTextr_SetTexturePath( TCHAR* strTexturePath );
  53.  
  54. //-----------------------------------------------------------------------------
  55. // Name: TextureContainer
  56. // Desc: Linked list structure to hold info per texture
  57. //-----------------------------------------------------------------------------
  58. struct TextureContainer
  59. {
  60.     TextureContainer* m_pNext;   // Linked list ptr
  61.  
  62.     TCHAR   m_strName[MAX_PATH]; // Name of texture (doubles as image filename)
  63.     DWORD   m_dwWidth;
  64.     DWORD   m_dwHeight;
  65.     DWORD   m_dwStage;           // Texture stage (for multitexture devices)
  66.     DWORD   m_dwBPP;
  67.     DWORD   m_dwFlags;
  68.     BOOL    m_bHasAlpha;
  69.     UINT    m_nRes;
  70.  
  71.     LPDIRECTDRAWSURFACE7 m_pddsSurface; // Surface of the texture
  72.     HBITMAP m_hbmBitmap;         // Bitmap containing texture image
  73.     DWORD*  m_pRGBAData;
  74.  
  75. public:
  76.     HRESULT LoadImageData();
  77.     HRESULT LoadBitmapFile( TCHAR* strPathname );
  78.     HRESULT Restore( LPDIRECT3DDEVICE7 pd3dDevice );
  79.     HRESULT CopyBitmapToSurface();
  80.     HRESULT CopyRGBADataToSurface();
  81.  
  82.     TextureContainer( TCHAR* strName, DWORD dwStage, DWORD dwFlags, UINT nRes = NULL );
  83.     ~TextureContainer();
  84. };
  85.  
  86.  
  87.  
  88. #endif // D3DTEXTR_H
  89.